package trabajoISW2.tests;

import java.util.Calendar;

import org.junit.Before;
import org.junit.Test;

import trabajoISW2.domain.contracts.IUser;
import trabajoISW2.domain.exceptions.WrongNameException;
import trabajoISW2.domain.implementations.Gender;




public class UserTestSuite {
	
	IUser u;
	SuperTest st;
	
	@Before
	public void setup(){
		st = new SuperTest();
		st.inicializa();
		u = st.user2;
	}
	
	//Tests de setUserId
	
	@Test
	public void testSetUserId(){
		u.setUserId("usuario");
				
	}
	
	@Test(expected = WrongNameException.class)
	public void testSetUserId1(){
		u.setUserId(null);
	}
	@Test(expected = WrongNameException.class)
	public void testSetUserId2(){
		u.setUserId("");
	}
	
	
	//Tests setName
	@Test
	public void testSetName(){
		u.setName("prueba");
				
	}
	
	@Test(expected = WrongNameException.class)
	public void testSetName1(){
		u.setName(null);
	}
	@Test(expected = WrongNameException.class)
	public void testSetName2(){
		u.setName("");
	}
	
	//Tests setSurname
	@Test
	public void testSetSurname(){
		u.setSurname("prueba");
				
	}
	
	@Test(expected = WrongNameException.class)
	public void testSetSurname1(){
		u.setSurname(null);
	}
	@Test(expected = WrongNameException.class)
	public void testSetSurname2(){
		u.setSurname("");
	}
	
	//Tests setEmail
	@Test
	public void testSetEmail(){
		u.setEmail("prueba");
				
	}
	
	@Test(expected = WrongNameException.class)
	public void testSetEmail1(){
		u.setEmail(null);
	}
	@Test(expected = WrongNameException.class)
	public void testSetEmail2(){
		u.setEmail("");
	}
	
	//Tests setBirthdate
	@Test
	public void testSetBirthdate(){
		Calendar d = Calendar.getInstance();
		u.setBirthdate(d);
				
	}
	
	@Test(expected = NullPointerException.class)
	public void testSetBirthdate1(){
		u.setBirthdate(null);
	}
	@Test(expected = IllegalArgumentException.class)
	public void testSetBirthdate2(){
		Calendar c = Calendar.getInstance();
		c.set(2013, 10,20);
		u.setBirthdate(c);
		
	}


	//Tests setGender
	@Test
	public void testSetGender(){
		u.setGender(Gender.Male);
		u.setGender(Gender.Female);
				
	}
	
	@Test(expected = IllegalArgumentException.class)
	public void testSetGender1(){
		u.setGender(null);
	}
	
	
	//Tests setPassword
	@Test
	public void testSetPassword(){
		u.setPassword("password");
				
	}
	
	@Test(expected = WrongNameException.class)
	public void testSetPassword1(){
		u.setPassword(null);
	}
	@Test(expected = WrongNameException.class)
	public void testSetPassword2(){
		u.setPassword("");
	}
	@Test(expected = WrongNameException.class)
	public void testSetPassword3(){
		u.setPassword("");
	}
	
}
